package com.tengju.settlement.domain.model.depository;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 银行卡所属类型
 *
 * @author 大木
 * @date 2021/12/07
 */
@Getter
@AllArgsConstructor
public enum BankCardType {

    PERSONAL(3,3,2,"个人账户"),
    PUBLIC(1,1,1,"对公账户"),
    ;

    Integer innerVal;
    Integer financeVal;
    Integer abmVal;
    String desc;

    public static BankCardType ofInnerCode(Integer innerCode) {
        if (innerCode == null) {
            return null;
        }
        for (BankCardType type : values()) {
            if (type.innerVal.equals(innerCode)) {
                return type;
            }
        }
        return null;
    }

    public static BankCardType ofFinanceCode(Integer financeCode) {
        if (financeCode == null) {
            return null;
        }
        for (BankCardType type : values()) {
            if (type.financeVal.equals(financeCode)) {
                return type;
            }
        }
        return null;
    }

    public static BankCardType ofAbmCode(Integer abmCode) {
        if (abmCode == null) {
            return null;
        }

        for (BankCardType type : values()) {
            if (type.abmVal.equals(abmCode)) {
                return type;
            }
        }
        return null;
    }

    /**
     * 获取鉴权类型
     *
     * @return {@link VerifyType}
     */
    public VerifyType getVerifyType(){
        if (this == BankCardType.PERSONAL) {
            return VerifyType.UNION_PAY_VERIFY;
        } else if (this == BankCardType.PUBLIC) {
            return VerifyType.SMALL_AMOUNT_VERIFY;
        }
        return null;
    }

    /**
     * 获得证件类型
     *
     * @return {@link LicenseType}
     */
    public LicenseType getLicenseType(){
        if (this == BankCardType.PERSONAL) {
            return LicenseType.ID_CARD;
        } else if (this == BankCardType.PUBLIC) {
            return LicenseType.SOCIAL_CREDIT;
        }
        return null;
    }

}
